Ext.require([
    'AM.data.OutputConfig'
]);


Ext.define('AM.data.OutputNode', {
    singleton:true,

    tempNode:function () {
        var tempRoot_node = document.createElement('tempRoot');
        return tempRoot_node;
    },


    pptNode:function (ppt_name) {
        var pptNode = document.createElement('ppt');
        pptNode.setAttribute('ppt-name', ppt_name);
        return pptNode;
    },


    pageNode:function (o) {
        var config = AM.data.OutputConfig.pageConfig(o);
        var node = document.createElement('page');

        this._setAttributes(node, config);

        return node;
    },


    cmpNode:function (o) {
        var factory = AM.data.OutputConfig;
        var config = null;
        var node = null;
        var tagName = null;
        switch (o.xtype) {
            case 'xbxText':
                config = factory.textConfig(o);
                tagName = 'text';
                break;
            case 'xbxImage':
                config = factory.imageConfig(o);
                tagName = '_image';
                break;
            case 'xbxAudio':
                config = factory.audioConfig(o);
                tagName = 'audio';
                break;

        }
        node = document.createElement(tagName);
        this._setAttributes(node, config);

        return node;
    },


    _setAttributes: function (node, config) {
        for (var p in config) {
            if (config[p] == null)
                continue;
            node.setAttribute(p, config[p]);
        }
    }


})